<div class="row">
	<div class="bill-right" style="margin:0;width:100%;">
		<form>
			<div class="box">
				<div class="box-header">
					<div class="row RowSearchWork">
						<div class="col-sm-12">
							<div class="form-group">
		                        <div class="form-inline">
		                            <div class="form-group ml10">
		                                <label class="control-label">交易日期：</label>
		                                <input type="text" class="form-control form_datetime" id="starTime2" />
		                            </div>
		                            <div class="form-group">
		                                <label class="control-label hidden-xs" style="width: inherit;"> 至 </label>
		                                <input type="text" class="form-control form_datetime" id="endTime2" />
		                            </div>
									<div class="form-group bill-buttonarea" style="text-align: center;">
		                            	<input type="hidden" id="accountRivalNumber" value="${accountRivalNumber!}"/>
		                            	<input type="hidden" id="accountRival2" value="${accountRival!}"/>
		                            	<input type="hidden" id="ariseDate" value="${ariseDate!}"/>
		                            	<input type="hidden" id="ariseMoney" value="${ariseMoney!}"/>
		                            	<input type="hidden" id="organizationNumber" value="${organizationNumber!}"/>
		                            	<input type="hidden" id="organizationName" value="${organizationName!}"/>
		                            	<input type="hidden" id="tellerNumber" value="${tellerNumber!}"/>
		                            	<input type="hidden" id="caseId" value="${caseId!}"/>
										<input type="button" class="btn btn-primary" onclick="queryList2();" value="分析" />
									</div>
		                        </div>
	                        </div>
						</div>
					</div>
				</div>
				<div class="box-body">
					<table id="table2" style="width:2400px;"></table>
				</div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
	var caseId="${caseId!}";
	$(".form_datetime").datepicker({
	    format: "yyyy-mm-dd",
	    autoclose: true,
	    language: 'zh-CN',
	    pickerPosition: "bottom-left"
	});
	$(document).ready(function() {
	    $('#table2').bootstrapTable({
            method : 'post', // 服务器数据的请求方式 get or post
            contentType : "application/x-www-form-urlencoded",
	        url: "${ctx}/commonAccount/billDetails",
	        //请求数据url
	        queryParams: function(params) {
	            let accountRivalNumber = $.trim($("#accountRivalNumber").val());
	            let accountRival = $.trim($("#accountRival2").val());
	            let ariseDate = $.trim($("#ariseDate").val());
	            let ariseMoney = $.trim($("#ariseMoney").val());
	            let organizationNumber = $.trim($("#organizationNumber").val());
	            let organizationName = $.trim($("#organizationName").val());
	            let tellerNumber = $.trim($("#tellerNumber").val());
	            let starTime = $.trim($("#starTime").val()) == "" ? $.trim($("#starTime2").val()) : $.trim($("#starTime").val());
	            let endTime = $.trim($("#endTime").val()) == "" ? $.trim($("#endTime2").val()) : $.trim($("#endTime").val());
	            return {
	                pageNumber: (params.offset / params.limit),//页码
	                pageSize: params.limit,//页面大小
	                accountRivalNumber: accountRivalNumber,
	                accountRival: accountRival,
	                ariseDate: ariseDate,
	                ariseMoney: ariseMoney,
	                organizationNumber: organizationNumber,
	                organizationName: organizationName,
	                tellerNumber: tellerNumber,
	                checkedAccount: _checkedAccount.join(','),
	                starTime: starTime,
	                caseId:caseId,
	                endTime: endTime,
                    sortName:this.sortName,
                    sortOrder:this.sortOrder
	            };
	        },
	        striped: true,
	        showHeader: true,//是否显示行间隔色
	        pagination: true,//是否显示分页（*）
	        sidePagination: 'server',
	        strictSearch: true,//服务器端分页
	        resizable: true,
	        pageNumber: 1,
            pageSize:30,
            pageList:[30,50,100,150,200],
	        //表格的列
	        columns: [
	            {
	            field: 'accountBodyNumber',
	            //域值
	            title: '本人账号',
	            //内容
	            visible: true,
	            //false表示不显示
	            width: '15%'
	        },
	        {
	            field: 'accountBody',
	            //域值
	            title: '本人户名',
	            //标题
	            visible: true,
	            //false表示不显示
	            sortable: false,
	            //启用排序
	            width: '20%'
	        },
	        {
	            field: 'accountBodyCard',
	            //域值
	            title: '本人卡号',
	            //标题
	            visible: true,
	            //false表示不显示
	            sortable: false,
	            //启用排序
	            width: '20%',
                formatter: function(value, row, index){
                    var html='<a href="javascript:void(0)" title="单机打开交易详情" onclick="billDetail(\''+row.accountBodyCard+'\')">'+value+'</a>'
                    return html;
                }
	        },
	        {
	            field: 'accountRivalNumber',
	            //域值
	            title: '对方账号',
	            //内容
	            visible: true,
	            //false表示不显示
	            width: '10%'
	        },
	        {
	            field: 'accountRival',
	            //域值
	            title: '对方户名',
	            //标题
	            visible: true,
	            //false表示不显示
	            sortable: false,
	            //启用排序
	            width: '20%'
	        },
	        {
	            field: 'accountRivalCard',
	            //域值
	            title: '对方卡号',
	            //标题
	            visible: true,
	            //false表示不显示
	            sortable: false,
	            //启用排序
	            width: '20%'
	        },
	        {
	            field: 'sign',
	            //域值
	            title: '存取',
	            //内容
	            visible: true,
	            //false表示不显示
	            width: '10%',
	            formatter: function(value, row, index) {
	                if (value) {
	                    return '支出';
	                } else {
	                    return '收入';
	                }
	            }
	        },
	        {
	            field: 'accountMoney',
	            //域值
	            title: '发生额',
	            //内容
	            visible: true,
	            //false表示不显示
                sortable: true,
	            width: '10%',
                formatter:function (value,row,index) {
                	if(!value) return 0;
                    if (Number.isInteger(value)) {
                        return value.toString().replace(/(\d)(?=(\d{3})+$)/g,'$1,');
                    } else {
                        return value.toString().replace(/(\d)(?=(\d{3})+\.)/g,'$1,');
                    }
                }
	        },
	        {
	            field: 'surplusMoney',
	            //域值
	            title: '本次余额',
	            //内容
	            visible: true,
	            //false表示不显示
	            width: '10%',
                sortable: true,
                formatter:function (value,row,index) {
                	if(!value) return 0;
                    if (Number.isInteger(value)) {
                        return value.toString().replace(/(\d)(?=(\d{3})+$)/g,'$1,');
                    } else {
                        return value.toString().replace(/(\d)(?=(\d{3})+\.)/g,'$1,');
                    }
                }
	        },
	        {
	            field: 'tradeDate',
	            //域值
	            title: '交易日期',
	            //内容
	            visible: true,
	            //false表示不显示
	            width: '20%',
                sortable: true,
	            formatter: function(value, row, index) {
	                return changeDateFormat(value)
	            }
	        },
	        {
	            field: 'contentAbstract',
	            //域值
	            title: '摘要',
	            //内容
	            visible: true,
	            //false表示不显示
	            width: '10%'
	        },
	        {
	            field: 'currency',
	            //域值
	            title: '币种',
	            //内容
	            visible: true,
	            //false表示不显示
	            width: '10%'
	        },{
	            field: 'ipAddress',
	            //域值
	            title: 'ip地址',
	            //内容
	            visible: true,
	            //false表示不显示
	            width: '10%'
	        },
	        {
	            field: 'remarks',
	            //域值
	            title: '交易备注',
	            //内容
	            visible: true,
	            //false表示不显示
	            width: '10%'
	        },
	        ]
	    });
	});
	/*bootstrap table*/
	function queryList2() {
	    $("#table2").bootstrapTable('refresh', {
	        pageNumber2: 1
	    });
	};
    /* 详情跳转 */
    function billDetail(accountBodyNumber){
        base.getView({
            url:"${ctx}/commonAccount/billDetailsGO?accountBodyNumber="+accountBodyNumber+"&caseId="+caseId,
            success:function(result){
                bootbox.dialog({
                    message:result,
                    size:"large",
                    boxCss:{"width":"1270px"},
                    closeButton : true
                })
            }
        });
    };
	
	//转换日期格式(时间戳转换为datetime格式)
	function changeDateFormat(cellval) {
	    var dateVal = cellval + "";
	    if (cellval != null) {
	        var date = new Date(parseInt(dateVal.replace("/Date(", "").replace(")/", ""), 10));
	        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
	        var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
	        var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
	        var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
	        var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
	        return date.getFullYear() + "-" + month + "-" + currentDate + " " + hours + ":" + minutes + ":" + seconds;
	    }
	};
</script>
